package seventhquestion;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Socket socket = null;
        PrintWriter pw = null;
        BufferedReader br = null;
        try {
            socket = new Socket("localhost",8888);
            pw = new PrintWriter(socket.getOutputStream(),true);
            br = new BufferedReader(new InputStreamReader(socket.getInputStream()));

            while (true){
                System.out.println("请输入消息：");
                String info = scanner.next();
                if (info.equals("溜了溜了")){
                    pw.println("溜了溜了");
                    break;
                }
                pw.println(info);
            }
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            if (socket!=null){
                try {
                    socket.close();
                }catch (IOException e){
                    e.printStackTrace();
                }

            }
        }

    }
}
